home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS05.ADF / IFF / giocall.c2 < prev    next >
Text File  |  1986-04-20  |  2KB  |  44 lines

  1.  
  2. /*--------------------------------------------------------------*/
  3. /*  GIOCall.c:  An example of calling the Generic I/O Speed-up. */
  4. /*            1/23/86                        */
  5. /*                                                              */
  6. /* By Jerry Morrison and Steve Shaw, Electronic Arts.           */
  7. /* This software is in the public domain.                       */
  8. /*                                                              */
  9. /* This version for the Commodore-Amiga computer.               */
  10. /*                                                              */
  11. /*--------------------------------------------------------------*/
  12.     main(...) {
  13.     LONG file;
  14.     int success;
  15.     ...
  16.     success = (0 != (file = GOpen(...)));
  17.     /* A TmpRas is a good buffer to use for a variety of short-term uses.*/
  18.     if (success)
  19.      success = PutObject(file, ob, tmpRas.RasPtr, tmpRas.Size);
  20.     success &= (0 <= GClose(file));
  21.     }
  22.  
  23. /*----- PutObject writes a DVCS object out as a disk file.-----*/
  24. BOOL PutObject(file, ob, buffer, bufsize)
  25.     LONG file;  struct Object *ob;  BYTE *buffer;  LONG bufsize; {
  26.     int success = TRUE;
  27.  
  28.     if (bufsize > 2*BODY_BUFSIZE) {
  29.      /* Give buffer to speed-up writing.*/
  30.      GWriteDeclare(file, buffer+BODY_BUFSIZE, bufsize-BODY_BUFSIZE);
  31.      bufsize = BODY_BUFSIZE;  /* Used by PutObject for other purposes.*/
  32.      }
  33.     ...
  34.      /* Use GWrite and GSeek instead of Write and Seek.*/
  35.     success &= (0 <= GWrite(file, address, length));
  36.     ...
  37.     success &= (0 <= GWriteUndeclare(file));
  38.           /* Release the speed-up buffer.*/
  39.           /* This is not necessary if GClose is used to close the file,
  40.            * but it can't hurt.*/
  41.     return( (BOOL)success );
  42.     }
  43.  
  44.